package com.cancer.application;

import java.io.IOException;

import javax.servlet.ServletException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cancer.biz.common.SysConfigUtils;
import com.cancer.biz.common.exception.SysDefaultUncaughtExceptionHandler;
import com.cancer.common.web.ApplicationContextUtils;

/**
 * @Company GeekPlus
 * @Project beetle
 * @since 1.0.0
 * @Author bai
 * @Date 201年10月10日 下午5:15:01
 * @Description 整个应用启动类
 */
public class AppStartUpServlet extends BaseServlet {
	private static Logger logger = LoggerFactory.getLogger(AppStartUpServlet.class);
	private static final long serialVersionUID = 1L;
	
	public AppStartUpServlet() {
		super();
	}

	@Override
	public void init() throws ServletException {
		ApplicationContextUtils.initialize(this.getServletContext());
		// 1.从数据库系统配置表中读出信息到内存中
		try {
			SysConfigUtils.init();
		} catch (IOException e2) {
			logger.error("SysConfigUtils.initSysConfigUtils(): file not find!");
			e2.printStackTrace();
		}
		// 2.获取token和jsticket到内存中
		getAccessTokenAndJSTicket();
		// 线程异常后如果未被catch，则统一输出其错误堆栈
		Thread.setDefaultUncaughtExceptionHandler(new SysDefaultUncaughtExceptionHandler());
		logger.info("系统启动完毕");
	}

}
